package cn.iocoder.yudao.module.api.pay.bill.enums;

import cn.iocoder.yudao.framework.business.basic.enums.EnumCodable;
import com.baomidou.mybatisplus.annotation.EnumValue;
import lombok.AllArgsConstructor;
import lombok.Getter;

import java.util.Objects;
import java.util.stream.Stream;

/**
 * 账单业务类型枚举
 */
@Getter
@AllArgsConstructor
public enum BillTypeEnum implements EnumCodable {

    UNKNOWN("undefined", "未知"),

    MEMBER_REGISTER_BY_SELF("member_register_by_self", "自行注册"),
    MEMBER_REGISTER_BY_INVITE("member_register_by_invite", "受邀注册"),

    RECHARGE("recharge", "充值"),
    RECHARGE_REFUND("recharge_refund", "充值退款"),

    COMMISSION_UNFREEZE("commission_unfreeze", "佣金结算"),
    COMMISSION_CANCEL("commission_cancel", "佣金取消"),
    COMMISSION_CASH_OUT("commission_cash_out", "佣金提现"),

    PAY_SHOP("pay_shop", "商家缴费"),
    PAY_VIP("pay_vip", "购买/续费会员"),
    PAY_AGENCY("pay_agency", "招商人员缴费"),
    PAY_ALLIANCE("pay_alliance", "云盟商缴费"),
    PAY_BONUS_BENEFIT("pay_bonus_benefit", "购买分红权限"),
    PAY_PRODUCT("pay_product", "购买产品"),
    PAY_PRODUCT_REFUND("pay_product_refund", "购买产品退款"),
    PAY_GROUPON_PACKAGE("pay_groupon_package", "购买团购套餐"),
    PAY_AD_PLAN("pay_ad_plan", "投放广告"),
    PAY_OFFLINE_SCAN("pay_offline_scan", "扫码付款"),

    CASH_OUT_SUCCESS("cash_out_success", "提现成功"),
    CASH_OUT_FAILURE("cash_out_failure", "提现失败"),

    SYSTEM_ADJUST("system_adjust", "系统调整"),

    CRYPTOCURRENCY_DEDUCTION("cryptocurrency_deduction", "抵扣现金"),
    CRYPTOCURRENCY_INCREMENT("cryptocurrency_increment", "增值"),

    EXCHANGE_MONEY("exchange_money", "兑换零钱"),
    EXCHANGE_PRODUCT("exchange_product", "兑换产品"),

    TRANSFER_INPUT("transfer_in", "转入"),
    TRANSFER_OUTPUT("transfer_out", "转出"),

    REVENUE_UNFREEZE("revenue_unfreeze", "营业收入"),
    REVENUE_CANCEL("revenue_cancel", "营业收入取消"),
    REVENUE_GIFT("revenue_gift", "赠品分账"),
    REVENUE_CASH_OUT("revenue_cash_out", "营业收入提现"),

    RED_PACKET_GRANTED("red_packet_granted", "红包发放"),
    RED_PACKET_USED("red_packet_used", "红包抵扣"),

    ;

    @EnumValue
    private final String code;
    private final String name;

    public static BillTypeEnum codeOf(String code) {
        return Stream.of(values())
                .filter(p -> Objects.equals(p.code, code))
                .findAny()
                .orElse(UNKNOWN);
    }

}
